package com.itouchtv.yang.library.page;

import com.itouchtv.yang.core.tools.Log;
import com.itouchtv.yang.library.element.PageElement;
import org.openqa.selenium.By;

import java.util.Objects;

public class AppuimObject extends PageObject {

    private AppuimObject(){}

    public static AppuimObject get(){
        PageObject page = CommPageObject.pageObject.get();
        if (Objects.isNull(page)){
            return new AppuimObject();
        }else return (AppuimObject) page;
    }

    @Override
    public void clickElement(String elementName) {
        driver.touchPress(findElement(elementName));
    }

    @Override
    public void mouseClickElement(String elementName) {
        driver.touchPress(findElement(elementName));
    }

    @Override
    public void clickOneOfElements(String elementName,String text){
        driver.touchPress(findElementFromList(elementName,text));
    }
    
    @Override
    PageElement findElement(String elementName) {
        By by = bys.get(elementName);
        Log.logger.info("定位元素："+elementName);
        return driver.findElementNoFrame(by);
    }
}
